package zhihui.mobile.ui.express;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.flyco.tablayout.SlidingTabLayout;
import com.zgm.utils.ui.UiTextHeader;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;
import zhihui.mobile.R;
import zhihui.mobile.presenter.IPresenter;
import zhihui.mobile.ui.BaseFragmentActivity;
import zhihui.mobile.ui.MyOnClickListener;

/**
 * Created by Administrator on 2017/9/16.
 */

public class ExpressActivity extends BaseFragmentActivity {
    @Bind(R.id.express_title_layout)
    UiTextHeader expressTitleLayout;
    @Bind(R.id.express_title_sliding_tab)
    SlidingTabLayout expressTitleSlidingTab;
    @Bind(R.id.express_title_viewpager)
    ViewPager expressTitleViewpager;

    private String[] titles = {"收到的包裹", "寄出的包裹"};
    private ArrayList<Fragment> fragments;

    @Override
    public void initView() {


    }

    @Override
    protected int getLayoutResId() {
        return R.layout.exprees_activity;
    }

    @Override
    protected IPresenter[] getPresenters() {
        return new IPresenter[0];
    }

    @Override
    protected void onInitPresenter() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ButterKnife.bind(this);
        initData();
    }

    private void initData() {
        expressTitleLayout.setTitle("快递包裹");
        expressTitleLayout.setRightText("查看历史");
        expressTitleLayout.setLeftBottonIcon(R.drawable.shop_back);
        expressTitleLayout.setLeftButtonOnClickListener(new MyOnClickListener(this) {
            @Override
            public void onClick(View v) {
                super.onClick(v);
                finish();
            }
        });
        expressTitleLayout.setRightTextListener(new MyOnClickListener(this) {
            @Override
            public void onClick(View v) {
                super.onClick(v);
                startActivity(new Intent().setClass(ExpressActivity.this, ExpressHistoryActivity.class));
            }
        });
        fragments = new ArrayList<>();
        fragments.add(new ReceiveExpressFragment());
        fragments.add(new SendOffExpressFragment());
        expressTitleSlidingTab.setViewPager(expressTitleViewpager, titles, this, fragments);
        if (null == getIntent()) {
            expressTitleSlidingTab.setCurrentTab(getIntent().getIntExtra("type", 0));
        } else {
            expressTitleSlidingTab.setCurrentTab(getIntent().getIntExtra("type", 0));
        }

    }
}
